package com.kevin.service.redis;

import cn.hutool.extra.spring.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;

import javax.annotation.PostConstruct;

/**
 * Redis失效监听器
 *
 * @author wh
 * @date 2022/5/12 14:13
 */
@Slf4j
public class RedisExpireListener {

    /** 开始考试处理 */
    public static class ExamStartListener extends KeyExpirationEventMessageListener {
        public ExamStartListener(RedisMessageListenerContainer listenerContainer) {
            super(listenerContainer);
        }

        @Override
        public void onMessage(Message message, byte[] pattern) {
            String expiredKey = message.toString();
            log.info("失效key:{}", expiredKey);
        }
    }

}
